package com.isnmp.common.snmp.impl;

import java.util.List;
import java.util.Vector;

import org.snmp4j.Snmp;
import org.snmp4j.Target;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.util.DefaultPDUFactory;
import org.snmp4j.util.TableEvent;
import org.snmp4j.util.TableUtils;

import com.isnmp.common.base.MyException;

public class GetALLTableOIDAction {

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static List<List<String>> getAllOIDTableData(Snmp paramSnmp, Target paramTarget, List<String> paramList) throws MyException {
        Object localObject1;
        try {
            Vector localVector1 = new Vector();
            localObject1 = new OID[paramList.size()];
            for (int i = 0; i < paramList.size(); i++) {
                Object localObject2 = (String) paramList.get(i);
                //                localObject1[i] = new OID((String) localObject2);
                localVector1.add(new OID((String) localObject2));
            }
            Vector localVector2 = new Vector();
            Object localObject2 = new TableUtils(paramSnmp, new DefaultPDUFactory());
            List localList = ((TableUtils) localObject2).getTable(paramTarget, (OID[]) localObject1, null, null);
            Object localObject3;
            for (int j = 0; j < localList.size(); j++) {
                localObject3 = (TableEvent) localList.get(j);
                if (((TableEvent) localObject3).isError())
                    throw new MyException(Messages.getString("GetALLTableOIDAction.0") + ((TableEvent) localObject3).getErrorMessage());
                if (((TableEvent) localObject3).getException() != null)
                    throw new MyException(Messages.getString("GetALLTableOIDAction.1") + ((TableEvent) localObject3).getErrorMessage() + "," + ((TableEvent) localObject3).getException().getMessage());
                if (((TableEvent) localObject3).getStatus() != 0)
                    throw new MyException(Messages.getString("GetALLTableOIDAction.3") + ((TableEvent) localObject3).getErrorMessage());
                if ((((TableEvent) localObject3).getColumns() != null) && (((TableEvent) localObject3).getColumns().length >= 1))
                    localVector2.add(localObject3);
            }
            for (int j = 0; j < localVector2.size(); j++) {
                localObject3 = new Vector();
                TableEvent localTableEvent = (TableEvent) localVector2.get(j);
                String str = localTableEvent.getIndex().toString();
                ((List) localObject3).add(str);
                VariableBinding[] arrayOfVariableBinding = localTableEvent.getColumns();
                for (int k = 0; k < arrayOfVariableBinding.length; k++)
                    try {
                        VariableBinding localVariableBinding = arrayOfVariableBinding[k];
                        if (localVariableBinding != null) {
                            Variable localVariable = localVariableBinding.getVariable();
                            ((List) localObject3).add(localVariable.toString());
                        }
                    } catch (Exception localException2) {
                        localException2.printStackTrace();
                    }
                localVector1.add(localObject3);
            }
            return localVector1;
        } catch (Exception localException1) {
            localObject1 = Messages.getString("GetALLTableOIDAction.4") + paramTarget.getAddress() + Messages.getString("GetALLTableOIDAction.5") + localException1.getMessage();
        }
        throw new MyException((String) localObject1);
    }

    public static void main(String[] paramArrayOfString) {
        new GetAllAction();
    }
}